<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> {yun:}include file="$lietoustyle/public.htm"{/yun}
        <link rel="stylesheet" href="{yun:}$lietou_style{/yun}/css/jianli.css?v={yun:}$config.cachecode{/yun}" type="text/css">
        <script type="text/javascript" src="{yun:}$config.sy_weburl{/yun}/js/member_public.js?v={yun:}$config.cachecode{/yun}"></script>
    </head>

    <body>
        {yun:}include file="$lietoustyle/header.htm"{/yun}
        <div class="m_content">
            <div class="wrap">
                {yun:}include file="$lietoustyle/left.htm"{/yun}
                <div class="m_inner_youb fl">
                    <div class=admincont_box>
                        <div class="lt_m_tit"><span class="lt_m_tit_s">收银台</span></div>
						
						<iframe id="supportiframe" name="supportiframe" onload="returnmessage('supportiframe');" style="display:none"></iframe>
                        <form name="alipayment" class="layui-form" id="payform" action="" method="post" onsubmit="return payforms();" enctype="multipart/form-data">

                            <div class="clear"></div>

                            <div class="payment_boxtable">
                                <table class="" cellpadding="1" cellspacing="1" border="0">
                                    <tr>
                                        <th>订单编号</th>
                                        <th>购买商品</th>
                                        <th>金额</th>
                                    </tr>
                                    <tr>
                                        <td>{yun:}$order.order_id{/yun}</td>
                                        <td>
                                            <div class="pay_ment">
                                                {yun:}if $order.type==1{/yun}购买会员 {yun:}elseif $order.type=='2'{/yun}{yun:}$order.integral{/yun}{yun:}$config.integral_priceunit{/yun}{yun:}$config.integral_pricename{/yun} {yun:}elseif $order.type=='3'{/yun}银行转帐 {yun:}elseif $order.type=='4'{/yun}金额充值 {yun:}elseif $order.type=='5'{/yun}增值服务 {yun:}elseif $order.type=='6'{/yun}课程订购 {yun:}elseif $order.type=='18'{/yun}职位刷新 {yun:}elseif $order.type=='19'{/yun}下载简历 {yun:}elseif $order.type=='22'{/yun}发布职位 {yun:}/if{/yun}
                                            </div>
                                            <input type="hidden" name="dingdan" value="{yun:}$order.order_id{/yun}" />
                                            <input type="hidden" name="aliorder" value="{yun:}$order.order_id{/yun}" />
                                            <input type="hidden" name="oid" id="oid"value="{yun:}$order.id{/yun}" />
                                            <input type="hidden" name="alimoney" value="{yun:}$order.order_price{/yun}" />
                                            <input type="hidden" name="paytype" id="paytype" value="" />
                                            <input type="hidden" name="subject" value="{yun:}if $order.type==1{/yun}购买会员 {yun:}elseif $order.type=='2'{/yun}{yun:}$order.integral{/yun}{yun:}$config.integral_priceunit{/yun}{yun:}$config.integral_pricename{/yun} {yun:}elseif $order.type=='3'{/yun}银行转帐 {yun:}elseif $order.type=='4'{/yun}金额充值 {yun:}elseif $order.type=='5'{/yun}增值服务 {yun:}elseif $order.type=='6'{/yun}课程订购 {yun:}elseif $order.type=='18'{/yun}职位刷新 {yun:}elseif $order.type=='19'{/yun}下载简历 {yun:}elseif $order.type=='22'{/yun}发布职位 {yun:}/if{/yun}" />
                                        </td>
                                        <td>￥{yun:}$order.order_price{/yun}</td>
                                    </tr>
                                </table>

                                <div class="payment_boxlist_c">
                                    {yun:}if count($coupons) && !$order.coupon{/yun}
                                    <div class="payment_boxlist layui-form-item">
                                        <div class="layui-input-block fr" style="width: 600px;">
											<label class="layui-form-label">优惠券：</label>
                                            <input type="radio" id="coupon0" name="coupon" value="" title="暂不使用" checked="checked" money="" lay-filter="coupon"> 
											{yun:}foreach from=$coupons item=clist{/yun}
                                            <input type="radio" id="coupon{yun:}$clist.id{/yun}" name="coupon" value="{yun:}$clist.id{/yun}" title="{yun:}$clist.coupon_name{/yun}" money="{yun:}$clist.coupon_amount{/yun}" lay-filter="coupon"> 
											{yun:}/foreach{/yun}
											<input type="hidden" id="camount" value=""> 
                                        </div>
                                    </div>
                                    {yun:}/if{/yun} 
                                    
                                    {yun:}if $config.com_integral_online==1 && $order.type==1 && !$order.order_dkjf && $config.member_meal!=1{/yun}
                                    <div class="payment_boxlist">
                                        <div class="layui-input-inline">
                                            <input name="type_switch" lay-filter="type_switch" lay-skin="switch" lay-text="开启|关闭" type="checkbox">
                                            <div class="layui-form-mid layui-word-aux">积分抵扣： 当前共 {yun:}$statis.integral{/yun}积分 </div>
                                        </div>
                                    </div>

                                    <div class="payment_boxlist" style="display:none;" id="input_integral">
                                    	积分抵扣数量：
                                        <input type="text" id="i_integral" name="dkjf" placeholder="" class="payment_boxdk" onkeyup="checkNum('{yun:}$statis.integral{/yun}','{yun:}$config.integral_proportion{/yun}');" oninput="myFunction(this)">
                                    </div>
                                    {yun:}/if{/yun}
                                </div>

                                <div class="payment_boxlist_fk">
                                	实付款
                                    <span class="payment_boxlist_fk_n">￥
          							<span id="order_price">{yun:}$order.order_price{/yun}</span>
                                    </span>
                                </div>
								
								{yun:}if $config.tenpay=='1'||$config.bank=='1'||$config.alipay=='1' || $config.wxpay=='1'{/yun}

                                <div class="payment_boxlist_zf" id="pay_style">
									{yun:}if $config.bank=='1'&&is_array($rows)&&$rows{/yun}<span class="payment_boxlist_zf_s" id="otherpay" onclick="paycheck('otherpay');"><i class="payment_boxlist_zf_icon payment_boxlist_zf_icon_qt"></i>其他支付方式</span>{yun:}/if{/yun}
									{yun:}if $config.tenpay=='1'{/yun}<span class="payment_boxlist_zf_s" id="tenpay" onclick="paycheck('tenpay');"><i class="payment_boxlist_zf_icon payment_boxlist_zf_icon_cft"></i>财付通支付</span>{yun:}/if{/yun}
									{yun:}if $config.wxpay=='1'{/yun}<span class="payment_boxlist_zf_s" id="wxpay" onclick="paycheck('wxpay');"><i class="payment_boxlist_zf_icon payment_boxlist_zf_icon_wx"></i>微信支付</span>{yun:}/if{/yun}
									{yun:}if $config.alipay=='1'{/yun}<span class="payment_boxlist_zf_s" id="alipay" onclick="paycheck('alipay');"><i class="payment_boxlist_zf_icon payment_boxlist_zf_icon_zfb"></i>支付宝支付</span>{yun:}/if{/yun}
								</div>


                                <div class="bank_box other_pay" style="display: none;">
                                    <table width="100%" border="0" cellpadding="1" cellspacing="1" class="my_table_msg" style="background:#ddd">
                                        <tr>
                                            <th width="8%" height="30" align="center" bgcolor="#F7FAFF">银行名称</th>
                                            <th width="5%" height="30" align="center" bgcolor="#F7FAFF">开户人</th>
                                            <th width="12%" align="center" bgcolor="#F7FAFF">银行帐户</th>
                                            <th width="14%" align="center" bgcolor="#F7FAFF">开户行</th>
                                        </tr>
                                        {yun:}if is_array($rows){/yun} {yun:}foreach item=blist from=$rows{/yun}
                                        <tr>
                                            <td height="30" align="center" bgcolor="#FFFFFF">{yun:}$blist.bank_name{/yun}</td>
                                            <td height="30" align="center" bgcolor="#FFFFFF">{yun:}$blist.name{/yun}</td>
                                            <td align="center" bgcolor="#FFFFFF">{yun:}$blist.bank_number{/yun}</td>
                                            <td align="center" bgcolor="#FFFFFF">{yun:}$blist.bank_address{/yun}</td>
                                        </tr>
                                        {yun:}/foreach{/yun} {yun:}else{/yun}
                                        <tr>
                                            <td colspan="4" height="26" align="center" bgcolor="#FFFFFF">暂未添加银行</td>
                                        </tr>
                                        {yun:}/if{/yun}
                                    </table>

                                    <div class="bank_list_p_box">

                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">汇款银行：</span>
                                            <input type="text" id="bank_name" name="bank_name" class="bank_list_text" value="{yun:}if $order.bank_name{/yun}{yun:}$order.bank_name{/yun}{yun:}/if{/yun}" placeholder="例如：中国银行+沭阳开发区支行" />
                                        </div>
                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">汇入账号：</span>
                                            <input type="text" id="bank_number" name="bank_number" class="bank_list_text" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" value="{yun:}$order.bank_number{/yun}" />
                                        </div>
                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">汇款金额：</span>
                                            <input type="text" id="bank_price" name="bank_price" class="bank_list_text" value="{yun:}$order.order_price{/yun}" />
                                        </div>
                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">汇款时间：</span>
                                            <input type="text" id="bank_time" name="bank_time" class="bank_list_text" />
                                        </div>
                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">备注</span>
                                            <textarea name='order_remark' class="bank_textarea"></textarea>
                                        </div>
                                        <div class="bank_list_p">
                                            <span class="bank_list_p_s">上传汇款单：</span>
                                            <button type="button" class="layui-btn layui-btn-normal" id="noupload">选择文件</button>
                                            <input type="hidden" id="laynoupload" value="1" />
                                        </div>
                                        <script type="text/javascript">
                                            layui.use(['laydate'], function() {
                                                var laydate = layui.laydate,
                                                    $ = layui.$;
                                                laydate.render({
                                                    elem: '#bank_time'
                                                });
                                            });
                                        </script>

                                    </div>
                                </div>

                                <div class="payment_boxlist_zf_bth" id="order_pay">
                                    <input type="button" value="确认支付" class="payment_boxlist_zf_bth_a" onClick="CheckForm();">
                                </div>

                                <div class="payment_boxlist_zf_bth" id="integral_buy" style="display: none;">
                                    <a href="javascript:integral_buy('{yun:}$order.rating{/yun}','{yun:}$order.id{/yun}');">
                                        <input type="button" value="确认支付" class="payment_boxlist_zf_bth_a">
                                    </a>
                                </div>
								
								{yun:}else{/yun}
								<div class="con_banner_no" style="width:300px;"><span></span><em>网站已关闭支付接口，请联系管理员</em></div>
								{yun:}/if{/yun}
								
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="clear"></div>

        
        <div id="wxpayTx" style="display:none;">
            <div class="wx_payment" style="width:250px; padding: 10px 15px;">
                <div class="wx_payment_cont" style="width:250px">
                    <div class="wx_payment_ewm">正在加载微信二维码,请稍候....</div>
                </div>
                <div class="wx_payment_h2" style="width:250px">二维码有效时长为2小时，请尽快支付</div>
                <div class="wx_payment_tip" style="margin-left:40px;">
                    <div class="wx_payment_tip_left"><i class="wx_payment_tip_line1"></i><i class="wx_payment_tip_line2"></i><i class="wx_payment_tip_line3"></i></div>
                    <div class="wx_payment_tip_right">请使用微信扫一扫<br>扫描二维码支付</div>
                </div>
            </div>
        </div>

        
        <div id="payshow" style="width:450px; position:absolute;left:0px;top:0px; background:#fff; display:none;">
            <div class="payment_tip">请在新打开的支付页面上完成付款，付款完成前请不要关闭此窗口。<br>如您在支付过程中遇到问题，请联系客服：<span class="payment_tip_s">{yun:}$config.sy_freewebtel{/yun}</span></div>
            <div class="payment_bottom">
                <a href="index.php?c=paylog" class="payment_bottombutt">已完成付款</a>
                <a href="index.php?c=payment&id={yun:}$order.id{/yun}" class="payment_bottom_bth2">重新支付</a>
            </div>
        </div>
<script src="{yun:}$config.sy_weburl{/yun}/js/layui.upload.js?v={yun:}$config.cachecode{/yun}" type='text/javascript'></script>
<script>
function paycheck(type) {
	if(type == "wxpay") {
		document.getElementById('payform').action = "";
		$("#payform").attr("target", "supportiframe");
		$("#wxpay").addClass("payment_boxlist_zf_s_cur");
		 $("#otherpay").removeClass("payment_boxlist_zf_s_cur");
		$("#tenpay").removeClass("payment_boxlist_zf_s_cur");
		 $("#alipay").removeClass("payment_boxlist_zf_s_cur");
		 $("#paytype").val("wxpay");
		 $(".other_pay").hide();
	} else if(type == "alipay") {
		document.getElementById('payform').action = "../api/alipay/alipayto.php";
		$("#payform").attr("target", "_blank");
		$("#alipay").addClass("payment_boxlist_zf_s_cur");
		$("#otherpay").removeClass("payment_boxlist_zf_s_cur");
		$("#tenpay").removeClass("payment_boxlist_zf_s_cur");
		$("#wxpay").removeClass("payment_boxlist_zf_s_cur");
		$("#paytype").val("alipay");
		$(".other_pay").hide();
	} else if(type == "tenpay") {
		document.getElementById('payform').action = "../api/tenpay/index.php";
		$("#payform").attr("target", "_blank");
		$("#tenpay").addClass("payment_boxlist_zf_s_cur");
		$("#otherpay").removeClass("payment_boxlist_zf_s_cur");
		$("#alipay").removeClass("payment_boxlist_zf_s_cur");
		$("#wxpay").removeClass("payment_boxlist_zf_s_cur");
		$("#paytype").val("tenpay");
		$(".other_pay").hide();
	} else if(type == "otherpay") {
		document.getElementById('payform').action = "index.php?c=payment&act=paybank";
		$("#payform").attr("target", "supportiframe");
		$("#otherpay").addClass("payment_boxlist_zf_s_cur");
		$("#alipay").removeClass("payment_boxlist_zf_s_cur");
		$("#tenpay").removeClass("payment_boxlist_zf_s_cur");
		$("#wxpay").removeClass("payment_boxlist_zf_s_cur");
		$("#paytype").val("bank");
		$(".other_pay").show();
	}
}

	function CheckForm(){
		
		var money = parseFloat($("#camount").val());
		var orderPrice = parseFloat($("#order_price").html());

  		if(orderPrice<=money){ 
			var id = '{yun:}$order.id{/yun}';
			var coupon = $("input[name='coupon']:checked").val();
		    var integral = $("#dkjf").val();
 		
			var index = layer.load('执行中，请稍候...',0);
			
			$.ajax({
				async: false, 
				type: 'POST',  
				global:false,
				url: "index.php?c=payment&act=useCouponBuy",  
				data: {
					id:id,cid:coupon,integral:integral
				},  
				success: function(data){  
					layer.close(index);
					var data=eval('('+data+')'); 

					if(data.error==1){
						layer.msg(data.msg, 2,8);
						return false;
 					}else if(data.error==0){
						layer.msg(data.msg, 2, 9, function() {
							window.location.href = 'index.php?c=paylogtc';
						});
					}
				}  
			});
		}else{
			$('#payform').submit();
		}
	}


function payforms() {
	var id = '{yun:}$order.id{/yun}';
	var integral = $("#i_integral").val();
	var pay_bank = $("#paytype").val();
					
	if(pay_bank == '') {
		layer.msg('请选择支付方式！', 2, 8);return false;
	} else if(pay_bank == 'bank') {
		if($("#bank_name").val() == "") {
				layer.msg('请填写汇款银行！', 2, 8);return false;
		}
		if($("#bank_number").val() == "") {
			layer.msg('请填写汇入账号！', 2, 8);return false;
		}
		if($("#bank_price").val() == "") {
			layer.msg('请填写汇款金额！', 2, 8);return false;
		}
		if($("#bank_time").val() == "") {
			layer.msg('请填写汇款时间！', 2, 8);return false;
		}
	}

	$.post('index.php?c=payment&act=dkzf', {
		id: id,
		dkjf: integral
	}, function(data) {
		if(data) {
			data = eval('(' + data + ')');
			if(data.error == 1) {

				if(pay_bank == 'wxpay') {
					var orderId = '{yun:}$order.id{/yun}';
					var coupon = $("input[name='coupon']:checked").val();
					layer.load('执行中，请稍候...', 0);

					$.post('index.php?c=payment&act=wxurl', {
						orderId: orderId,
						coupon: coupon
					}, function(data) {
						layer.closeAll('loading');
						$('.wx_payment_ewm').html(data);
						$.layer({
							type: 1,
							title: '微信扫码支付',
							closeBtn: [0, true],
							border: [10, 0.3, '#000', true],
							area: ['320px', '400px'],
							page: {dom: "#wxpayTx"}
						});
						setInterval("wxorderstatus(" + orderId + ")", 3000);
					})
					return false;
				} else if(pay_bank !='bank'){
					$.layer({
						type: 1,
						title: '提示',
						closeBtn: [0, true],
						border: [10, 0.3, '#000', true],
						area: ['450px', '280px'],
						page: {dom: "#payshow"}
					});
				}

				layer.msg(data.msg, 2, 9);
			} else if(data.error == 2) {
				layer.msg(data.msg, 2, 8);return false;
			}
		}
	});
	if(pay_bank == 'wxpay') {
		return false;
	}
}

function wxorderstatus(orderid) {
	$.post('{yun:}$config.sy_weburl{/yun}/api/wxpay/wxorder.php', {
		orderid: orderid
	}, function(data) {
		if(data == 1) {
			window.location.href = '';
		}
	});
}

layui.use(['form'], function() {
	var form = layui.form,
		layer = layui.layer,
		$ = layui.$;

	form.on('switch(type_switch)', function(data) {
		var v = this.checked ? 1 : 2;
		if(v == 1) {
			$("#input_integral").show();
		} else {
			$("#i_integral").val('');
			$("#order_price").html('{yun:}$order.order_price{/yun}');
			$("#bank_price").val('{yun:}$order.order_price{/yun}');
			$("#pay_style").show();
			$("#order_pay").show();
			$("#integral_buy").hide();
			$("#input_integral").hide();
		}

	});

	form.on('radio(coupon)', function(data){
		var money = $(this).attr('money');
		$("#camount").val(money);
	});  
});


function accAdd(arg1, arg2) {
	var r1, r2, m;
	try {
		r1 = arg1.toString().split(".")[1].length
	} catch(e) {
		r1 = 0
	}
	try {
		r2 = arg2.toString().split(".")[1].length
	} catch(e) {
		r2 = 0
	}
	m = Math.pow(10, Math.max(r1, r2))
	return(arg1 * m + arg2 * m) / m
}

function accSub(arg1, arg2) {
	return accAdd(arg1, -arg2);
}

function accMul(arg1, arg2) {
	var m = 0,
		s1 = arg1.toString(),
			s2 = arg2.toString();
	try {
		m += s1.split(".")[1].length
	} catch(e) {}
	try {
		m += s2.split(".")[1].length
	} catch(e) {}
	return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}

function accDiv(arg1, arg2) {
	var t1 = 0,
		t2 = 0,
		r1, r2;
	try {
		t1 = arg1.toString().split(".")[1].length
	} catch(e) {}
	try {
		t2 = arg2.toString().split(".")[1].length
	} catch(e) {}
	with(Math) {
		r1 = Number(arg1.toString().replace(".", ""));
		r2 = Number(arg2.toString().replace(".", ""));
		return(r1 / r2) * pow(10, t2 - t1);
	}
}

function myFunction(_this) {
	_this.value = _this.value.replace(/[^0-9]/g, '');
}

function checkNum(integral, integral_pro) {
               
	var dkjf = $("#i_integral").val();
	var price = '{yun:}$order.order_price{/yun}';
	var price = parseInt(price);

	var need_integral = accMul(price, integral_pro);

	if(parseInt(integral) >= parseInt(need_integral)) {

		if(parseInt(dkjf) > parseInt(need_integral)) { 
			$("#i_integral").val(parseInt(need_integral));
			var price_n = accSub(price, accDiv(need_integral, integral_pro));
		} else {
			var price_n = accSub(price, accDiv(dkjf, integral_pro));
		}

	} else {

		if(parseInt(dkjf) > parseInt(integral)) {
			$("#i_integral").val(parseInt(integral));
			var price_n = accSub(price, accDiv(integral, integral_pro));
		} else {
			var price_n = accSub(price, accDiv(dkjf, integral_pro));
		}

	}

	if(price_n <= 0) {

		$("#order_price").html(0);

		$("#pay_style").hide();
		$("#order_pay").hide();

		$("#integral_buy").show();

	} else {

		$("#order_price").html(price_n);
		$("#bank_price").val(price_n);

		$("#pay_style").show();
		$("#order_pay").show();

		$("#integral_buy").hide();

	}
}

function integral_buy(id, orderid) { 

	$.post('index.php?c=pay&act=dkzf', {
		id: id,
		orderid: orderid
	}, function(data) {

		if(data) {
			data = eval('(' + data + ')');

			if(data.error == 1) {

				if(data.url) {
					layer.msg(data.msg, 2, 8, function() {
						window.location.href = data.url;
					});
				} else {
					layer.msg(data.msg, 2, 8);
				}

			} else if(data.error == 0) {
				layer.msg(data.msg, 2, 9, function() {
					window.location.href = 'index.php?c=paylogtc';
				});
			}
		}

	})
}
</script>
{yun:}include file="$lietoustyle/footer.htm"{/yun}